<template>
	<view class="page">
		<view class="box">
			<view class="content">
				请填写10字以上的问题描述以便我们提供更好的帮助！
			</view>
			<view class="inputBox">
				<input type="text" value="" v-model="feedbackContent" />
			</view>
			<button type="default" class="submitButton" hover-class="button-hover" @click="jumpBack(index)">确 定</button>
		</view>
	</view>
</template>

<script>
	import cloudbase from '@cloudbase/js-sdk'
	export default {
		data() {const currentDate = this.getDate({
				format: true
			})
			return {
				feedbackContent:'',
				openId:getApp().globalData.userInfo.openId,
				createTime:currentDate
			}
		},
		methods: {
			getDate: function(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
			
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			jumpBack:function(){
				if(this.feedbackContent == ''){
					uni.showToast({
						title:'请输入您的反馈',
						icon:'none'
					})
				}
				else{
					cloudbase.database().collection('feedback').add({
						openId:this.openId,
						createTime:this.createTime,
						feedbackContent:this.feedbackContent
					}).then(res=>{
						// console.log(res);
						if(res.id){
							uni.showToast({
								title:'反馈成功',
								icon:'none'
							})
							uni.redirectTo({
								url:'../submitSuccess/submitSuccess?index=1'
							})
						}
					})
				}
			}
		}
	}
</script>

<style>
.page{
	
		width: 750rpx;
		height: 1334rpx;
		display: flex;
		flex-direction: column;
		/* height: 1020rpx; */
		/* padding-bottom: 60px; */
		background-color: #F3F5F7;
}

	.box{
		width: 100%;
		/* height: 525rpx; */
		background-color: #fd973f;
		height: 420rpx;
		border-radius: 0 0 30% 30%;
	}
	.content{
		z-index: 5;
		width: 80%;
		height: 500rpx;
		margin-left: auto;
		margin-right: auto;
		margin-top: 100rpx;
		color: #FFFFFF;
		font-size: 35rpx;
	}
	.inputBox{
		width: 620rpx;
		height: 246rpx;
		margin-top: -300rpx;
		margin-left: auto;
		margin-right: auto;
		padding: 20rpx;
		background-color: #FFFFFF;
		border-radius: 32rpx;
		box-shadow: 0 5px 15px rgba(48,48,48,0.2);
		box-sizing: border-box;
	}
	
	.submitButton{
		width: 150rpx;
		height: 60rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		font-size: 20rpx;
		line-height: 60rpx;
		color: #FFFFFF!important;
		background-color: #fd973f!important;
	}
	.button-hover {
		background-color: rgba(0, 0, 0, 0.1) !important;
		opacity: 0.7;
	}
</style>
